<template>
    <z-paging
        auto-show-back-to-top
        ref="paging"
        v-model="dataList"
        @query="queryList"
        :fixed="false"
        height="100%"
    >
        <block v-for="(item, index) in dataList" :key="index">
            <order-card :orderInfo="item">
            </order-card>
        </block>
    </z-paging>
</template>

<script lang="ts" setup>
import { ref, shallowRef, watch } from 'vue'
import orderCard from './order-card.vue'
import orderFooter from '@/components/order-footer/index.vue'
import { apiOrderLists } from '@/api/order'
import { onShow } from '@dcloudio/uni-app'
import { useLockFn } from '@/hooks/useLockFn'


const paging = shallowRef<any>(null)
const dataList = ref<any>([])


// 页面跳转
const goPage = (url: string) => {
    uni.navigateTo({ url })
}
const { lockFn: queryList } = useLockFn(async (pageNo = 1, pageSize = 10) => {
    try {
        const { lists } = await apiOrderLists({
            orderType: 2,
            pageNo,
            pageSize
        })
        paging.value.complete(lists)
    } catch (e) {
        console.log('报错=>', e)
        //TODO handle the exception
        paging.value.complete(false)
    }
})

onShow(() => {
    setTimeout(() => {
        paging.value.reload()
    }, 300)
})
</script>

<style scoped></style>
